|
|
|
|
|
|
|
An added feature in this routine deserves mention. Because Visual Basic does not allow you to write to COUNTER data type fields, this routine checks the Attributes property of each bound column before attempting an update. If the field is a COUNTER data type, the routine does not attempt to write data to the column. Note again that the RSWrite routine is built as a Private Function. This function can be executed only by other methods within your OLE Server class. |
|
|
|
|
|
|
|
|
To simplify the management of data entry routines, your form allows users to update form controls only after they select the Edit or Add buttons on a form. The RSEnable routine gives you an easy way to turn on or off the Enabled property of all the bound controls on your form. You call this routine often from your button set routines. Add Listing 10.14 to the library. |
|
|
|
|
|
|
|
|
Listing 10.14. Coding the RSEnable function. |
|
|
|
|
|
|
|
|
Public Function RSEnable(frmTemp As Object, Toggle As Boolean)
'
' toggle the controls on/off
'
Dim ctlTemp As Control
Dim strTag As String
'
For Each ctlTemp In frmTemp.Controls
strTag = UCase(Trim(ctlTemp.Tag))
If strTag <> "" Then
ctlTemp.Enabled = Toggle
End If
If UCase(Trim(ctlTemp.Tag)) = UCase(Trim(strFocus)) Then
If Toggle = True Then
ctlTemp.SetFocus
End If
End If
Next
'
RSEnable = 0
Exit Function
'
LocalErr:
RSEnable = Err.Number
'
End Function |
|
|
|
|
|
|
|
|
Notice that the RSEnable routine checks the Focus property to see which input field should get the initial focus on the form. |
|
|
|
|
|